const app = getApp()

Page({ 
  data:{
    tabs:[],
    activeTab:0,
  },
  onLoad(){
    let tabItems = [{
      title:'全部',
      orderItems:[{
        id:1,
        orderDate:'2020-04-10',
        OrderType:'取快递',
        orderState:'已支付',
        amt:10,
        code:'ASB20200101',
        AppointTime:'2020-04-10 10:00',
        num:1,
        expresscode:'278978',
        orderType:0,
      },{
        id:2,
        orderDate:'2020-04-11',
        orderState:'未支付',
        amt:0,
        OrderType:'取快递',
        code:'ASB20200102',
        AppointTime:'2020-04-10 10:00',
        num:1,
        expresscode:'278978',
        orderType:0,
      },{
        id:3,
        toDoorTime:'2020-04-11 12:00',
        orderState:'已支付',
        amt:10,
        OrderType:'取快递',
        code:'ASB20200102',
        AppointTime:'2020-04-10 10:00',
        num:1,
        expresscode:'278978',
        orderType:1,
        OrderType:'扔垃圾',
        garbageType:'中型',
      },{
        id:4,
        toDoorTime:'2020-04-11 12:00',
        orderState:'已支付',
        amt:10,
        code:'ASB20200102',
        OrderType:'扔垃圾',
        AppointTime:'2020-04-10 10:00',
        num:1,
        expresscode:'278978',
        orderType:1,
        garbageType:'中型',
      }]
    },{
      title:'待付款',
      orderItems:[],
    },{
      title:'已付款',
      orderItems:[],
    },{
      title:'完成',
      orderItems:[],
    }]
    this.setData({
      tabs:tabItems
    })
  },
  onTabCLick(e) {
    const index = e.detail.index
    this.setData({activeTab: index})
  },
  onChange(e) {
    const index = e.detail.index
    this.setData({activeTab: index})
  },
  search: function (value) {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve([{text: '搜索结果', value: 1}, {text: '搜索结果2', value: 2}])
        }, 200)
    })
},
  selectResult: function (e) {
    console.log('select result', e.detail)
},
onReady() {
  // console.log('onReady')
  // this.setData({
  //   stickyContainer: () => wx.createSelectorQuery().select('#order-container')
  // })
},
  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    console.log('下拉刷新')
    wx.showLoading({
      title: '加载中',
      mask:true,
    })
    
    setTimeout(function () {
      wx.hideLoading()
    }, 2000)
  },
 /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    console.log('上拉加载更多')
  },
  onScroll:function(e){
    console.log('onScroll', e)
  },
  /**
   * 订单详情
   */
  detailOrder:function(e){
    console.log('删除ID=',e.currentTarget.dataset.id)
    console.log('删除订单类型=',e.currentTarget.dataset.ordertype)
  }
})